//
// Created by 党清浩 on 2021/9/28.
//
#include<stdio.h>
#include<stdlib.h>

#define  N  10
typedef struct {
    int max, min;    /*  Suitable  for  the  other  types  of  return  value  */
} Data;

void fun1(int a[], int n, Data *p) {
    int i, j, temp;
    for (i = 0; i < N; i++) {

        /* if (a[i]>p.max){
             p.max=a[i];
         }
         else(p.min>a[i]){
             p.min=a[i];
         }*/
        for (j = 0; j < N - 1 - i; j++) {
            if (a[j] > a[j + 1]) {
                temp = a[j];
                a[j] = a[j + 1];
                a[j + 1] = temp;
            }
        }
    }
    p->max = a[n - 1];
    p->min = a[0];
}

Data fun2(int a[], int n) {
    int i, j, temp;
    Data data;
    for (i = 0; i < N; i++) {
        for (j = 0; j < N - 1 - i; j++) {
            if (a[j] > a[j + 1]) {
                temp = a[j];
                a[j] = a[j + 1];
                a[j + 1] = temp;
            }
        }
    }
    data.max = a[n - 1];
    data.min = a[0];
    return data;
}

int main() {
    int a[N];
    int b[N];
    int i;
    Data d;
    printf("please  input  numbers  to  a:\n");

    for (i = 0; i < N; i++)
        scanf("%d", &a[i]);
    printf("please  input  numbers  to  b:\n");

    for (i = 0; i < N; i++)
        scanf("%d", &b[i]);

    fun1(a, N, &d);
    printf("In  array  a,  the  max  is  %d,  while  the  min  is  %d\n", d.max, d.min);

    d = fun2(b, N);
    printf("In  array  b,  the  max  is  %d,  while  the  min  is  %d\n", d.max, d.min);
    return 0;
}


